home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / System / ReqToolsLib / Source / reqtools / filereqmain.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-02  |  37.7 KB  |  1,539 lines

  1. /*
  2.     (C) 2000-2001 AROS - The Amiga Research OS
  3.     $Id: filereqmain.c,v 1.12 2001/06/18 16:59:00 stegerg Exp $
  4.  
  5.     Desc:
  6.     Lang: English
  7. */
  8.  
  9. /**************************************************************
  10. *                                                             *
  11. *      File/Font/Screenmode requester                         *
  12. *                                                             *
  13. *                                 (c) Nico François 1991-1994 *
  14. **************************************************************/
  15.  
  16. #include "filereq.h"
  17.  
  18. /* The AmigaOS V40 ScrollWindowRaster() function is buggy and
  19.    causes Enforcer Hits */
  20.    
  21. #define NO_SCROLLWINDOWRASTER 1
  22.  
  23. #ifdef  _AROS
  24.  
  25.     #define   DEBUG  1
  26.     #include  <aros/debug.h>
  27. #else
  28.  
  29.     #define   D(x)  
  30.  
  31. #endif
  32.  
  33.  
  34. /****************************************************************************************/
  35.  
  36. #ifdef _AROS
  37. #define fib_EntryType fib_DirEntryType
  38. #endif
  39.  
  40. /****************************************************************************************/
  41.  
  42. #ifndef MTYPE_APPWINDOW
  43. #define MTYPE_APPWINDOW        7    /* msg from an app window */
  44. #endif
  45.  
  46. /****************************************************************************************/
  47.  
  48. static const IPTR getstringtags[] = { RTGS_Width,180,RT_LockWindow,TRUE,
  49.                   RT_ReqPos,REQPOS_CENTERWIN,RT_ShareIDCMP,TRUE,TAG_END };
  50. static const IPTR ezreqtags[] = { RT_Underscore,'_',RTEZ_Flags,EZREQF_NORETURNKEY,
  51.                  TAG_MORE, (ULONG)&getstringtags[2] };
  52.  
  53.  
  54. /****************************************************************************************/
  55.  
  56. BOOL
  57. ExpandLink( GlobData *glob )
  58. {
  59. #ifndef _AROS
  60.     struct FileLock  *fl;
  61. #endif
  62.     BOOL              rc = FALSE;
  63.     LONG              res;
  64.  
  65.     *glob->winaddr = ( APTR ) -1;
  66.  
  67. #ifdef _AROS
  68.     res = ReadLink(NULL, glob->lock, glob->fib.fib_FileName, glob->linkbuf,
  69.            sizeof(glob->linkbuf));
  70. #else
  71.     fl = BADDR( glob->lock );
  72.     res = ReadLink(fl->fl_Task, glob->lock, glob->fib.fib_FileName, glob->linkbuf, sizeof(glob->linkbuf));
  73. #endif
  74.  
  75.     if(res != 0)
  76.     {
  77.     BPTR lock;
  78.  
  79.     if( ( lock = Lock( glob->linkbuf, SHARED_LOCK ) ) )
  80.     {
  81.         STRPTR end = FilePart( glob->linkbuf );
  82.  
  83.         if( end != glob->linkbuf )
  84.         {
  85.         *end = 0;
  86.         }
  87.  
  88.         Examine( lock, &glob->linkfib );
  89.         UnLock( lock );
  90.         rc = TRUE;
  91.     }
  92.     }
  93.  
  94.     *glob->winaddr = glob->reqwin;
  95.  
  96.     return( rc );
  97. }
  98.  
  99. /****************************************************************************************/
  100.  
  101. ULONG ASM SAVEDS PropReqHandler (
  102.     REGPARAM(a1, struct RealHandlerInfo *, glob),
  103.     REGPARAM(d0, ULONG, sigs),
  104.     REGPARAM(a0, struct TagItem *, taglist))
  105. {
  106.     struct IntuiMessage     *reqmsg, *imsg, im;
  107.     struct Gadget         *gad;
  108.     struct RealFileRequester     *freq;
  109.     struct RealFontRequester     *fontreq;
  110.     struct BufferData         *buff;
  111.     struct DiskfontBase     *DiskfontBase = glob->diskfontbase;
  112.     struct TagItem         *tag, *tstate;
  113.     struct AvailFontsHeader     *afh;
  114.     struct AvailFonts         *af;
  115.     struct ReqEntry         *entry;
  116.     struct DosList         *dlist;
  117.     struct AppMessage         *appmsg;
  118.     struct AssignList         *assignlist, *fontslist, **prevassign;
  119.     int             clicked, ctype, sel, val, code, qual, doubleclick, checkbox;
  120.     int             i, step, start, stop, shortage, buffsize, mon, doactgad, lastpos;
  121.     UBYTE             *fdir, *filename, *str, *str2, *str3, key;
  122.     ULONG             tagdata;
  123.     BPTR             parent;
  124.     APTR             winlock;
  125.     ULONG             id;
  126.  
  127.     /* uncomment if sigs is no longer ignored */
  128. //  if (glob->DoNotWait) sigs = SetSignal (0, 0);
  129.  
  130.     doactgad = !(glob->buttoninfo.lastcode);
  131.  
  132.     if (glob->reqtype == RT_FILEREQ)
  133.     {
  134.     freq = glob->freq;
  135.     filename = freq->filename;
  136.     fdir = freq->dirname;
  137.     }
  138.         
  139.     if (glob->reqtype == RT_FONTREQ)
  140.     {
  141.     fontreq = glob->fontreq;
  142.     filename = fontreq->fontname;
  143.     }
  144.     
  145.     buff = glob->buff;
  146.  
  147.     /* parse tags */
  148.     tstate = taglist;
  149.     while ((tag = NextTagItem ((const struct TagItem **)&tstate)))
  150.     {
  151.     tagdata = tag->ti_Data;
  152.     if (tag->ti_Tag > RT_TagBase)
  153.     {
  154.         switch (tag->ti_Tag)
  155.         {
  156.         case RTRH_EndRequest:
  157.             if (tagdata == REQ_OK)
  158.             return (LeaveReq (glob, filename));
  159.             
  160.             FreeAllCheckBuffer (glob);
  161.             
  162.             return (FALSE);
  163.            
  164.         }
  165.     }
  166.     }
  167.  
  168.     /* MAIN LOOP */
  169.  
  170.     if (glob->appwinport)
  171.     {
  172.     while ((appmsg = (struct AppMessage *)GetMsg (glob->appwinport)))
  173.     {
  174.         if (appmsg->am_Type == MTYPE_APPWINDOW)
  175.         {
  176.         if (appmsg->am_NumArgs >= 1)
  177.         {
  178.             NameFromLock (appmsg->am_ArgList->wa_Lock, fdir, 256);
  179.             my_SetStringGadget (glob->reqwin, glob->filegad,
  180.                     appmsg->am_ArgList->wa_Name);
  181.             NewDir (glob);
  182.         }
  183.         ReplyMsg ((struct Message *)appmsg);
  184.         goto iterate;
  185.         }
  186.     }
  187.     }
  188.  
  189.     if (glob->newdir)
  190.     {
  191.  
  192.     glob->disks = FALSE;
  193.     
  194.     if (!glob->bufferentry)
  195.     {
  196.         ClearFilesRect (glob);
  197.         ClearAndInitReqBuffer (glob);
  198.         AdjustScroller (glob);
  199.     }
  200.     else RethinkReqDisplay (glob);
  201.     
  202.     glob->selectedpos = -1;
  203.     glob->numselected = 0;
  204.     UpdateNumSelGad (glob);
  205.     glob->lastclicked = -1;
  206.     glob->exnext = FALSE;
  207.     
  208.     if (!glob->bufferentry)
  209.     {
  210.         if (glob->reqtype == RT_FILEREQ)
  211.         {
  212.         if (!glob->volumerequest)
  213.         {
  214.             /* Render LED before lock, for good behaviour with ArcHandler */
  215.             glob->ledon = TRUE;
  216.             RenderLED (glob);
  217.             if ((glob->lock = Lock (fdir, SHARED_LOCK)))
  218.             {
  219.             Examine (glob->lock, &glob->fib);
  220.             if (glob->fib.fib_EntryType <= 0)
  221.                 UnLockReqLock (glob);
  222.             }
  223.             else if ((glob->flags & FREQF_SAVE) &&
  224.                  fdir[strlen(fdir)-1] != ':' &&
  225.                  IoErr() != ERROR_DEVICE_NOT_MOUNTED)
  226.             {
  227.             struct TagItem tags[] =
  228.             {
  229.                 {RT_Window        , (IPTR)glob->reqwin    },
  230.                 {RT_IntuiMsgFunc    , (IPTR)&glob->intuihook},
  231.                 {TAG_MORE        , (IPTR)ezreqtags    }
  232.             };
  233.  
  234.             if (rtEZRequestA (GetStr (glob->catalog, MSG_CREATE_DRAWER),
  235.                       GetStr (glob->catalog, MSG_OK_BAR_CANCEL),
  236.                       NULL, &glob->drawerstr, tags))
  237.                 glob->lock = CreateDir (glob->drawerstr);
  238.             }
  239.              
  240.             if (!glob->lock)
  241.             {
  242.             glob->ledon = FALSE;
  243.             RenderLED (glob);
  244.             SetWinTitleFlash (glob->reqwin,
  245.                 GetStr (glob->catalog, MSG_DIR_ERROR));
  246.             FreeReqBuffer (glob->req);
  247.             ClearDisplayList (glob);
  248.             glob->nodir = TRUE;
  249.             }
  250.             else
  251.             {
  252.             i = strlen (fdir);
  253.             
  254.             if (fdir[i-1] == '/' && i > 1)
  255.             {
  256.                 if (fdir[i-2] != ':' && fdir[i-2] != '/') fdir[i-1] = 0;
  257.             }
  258.             
  259.             my_SetStringGadget (glob->reqwin, glob->drawergad, fdir);
  260.             glob->exnext = TRUE;
  261.             glob->nodir = FALSE;
  262.             /* first examine before ExNext */
  263.             Examine (glob->lock, &glob->fib);
  264.             StartTimer (glob, 500000);
  265.             glob->firsttimer = glob->quiet = TRUE;
  266.             
  267.             }
  268.             
  269.         } /* if (glob->reqtype == RT_FILEREQ) */
  270.         else
  271.         {
  272.             /* Volume requester */
  273.             AddDiskNames (glob, glob->volumerequest);
  274.  
  275.             if (fdir[0])
  276.             {
  277.             if (!FindCurrentPos (glob, fdir, MAXINT, VOLUME))
  278.                 FindCurrentPos (glob, fdir, MAXINT, ASSIGN);
  279.  
  280.             glob->buff->pos -= (glob->numentries - 1);
  281.  
  282.             if (glob->buff->pos < 0) glob->buff->pos = 0;
  283.  
  284.             glob->buff->gotopos = glob->buff->pos;
  285.             }
  286.  
  287.             RethinkReqDisplay (glob);
  288.             glob->disks = TRUE;
  289.             
  290.         } /* if (glob->reqtype == RT_FILEREQ) else ... */
  291.          
  292.         } /* if (glob->reqtype == RT_FILEREQ) */         
  293.         else if (glob->reqtype == RT_FONTREQ)
  294.         {
  295.         winlock = rtLockWindow (glob->reqwin);
  296.         ReqToolsBase->AvailFontsLock = TRUE;
  297.         afh = ReqToolsBase->AvailFontsHeader;
  298.  
  299.         dlist = LockDosList (LDF_DEVICES|LDF_ASSIGNS|LDF_READ);
  300.         dlist = FindDosEntry (dlist, "FONTS", LDF_DEVICES|LDF_ASSIGNS);
  301.         
  302.         if (afh)
  303.         {
  304.             if (!dlist) afh = NULL;
  305.             else
  306.             {
  307.             if (ReqToolsBase->FontsAssignType != dlist->dol_Type) afh = NULL;
  308.             else
  309.             {
  310.                 if (ReqToolsBase->FontsAssignLock != dlist->dol_Lock)
  311.                 afh = NULL;
  312.                 else
  313.                 {
  314.                 fontslist = ReqToolsBase->FontsAssignList;
  315.                 assignlist = dlist->dol_misc.dol_assign.dol_List;
  316.                 
  317.                 while (assignlist)
  318.                 {
  319.                     if (fontslist->al_Lock != assignlist->al_Lock)
  320.                     {
  321.                     afh = NULL;
  322.                     break;
  323.                     }
  324.                     fontslist = fontslist->al_Next;
  325.                     assignlist = assignlist->al_Next;
  326.                 }
  327.                 
  328.                 if (fontslist) afh = NULL;
  329.                 
  330.                 }
  331.             }
  332.             }
  333.             if (!afh) FreeReqToolsFonts();
  334.         }
  335.             
  336.         if (!afh)
  337.         {
  338.             buffsize = 2000;
  339.             for (;;)
  340.             {
  341.             if (!(afh = AllocVec (buffsize, 0))) break;
  342.             
  343.             shortage = AvailFonts ((STRPTR)afh, buffsize, AFF_DISK|AFF_MEMORY);
  344.             if (shortage)
  345.             {
  346.                 buffsize += shortage;
  347.                 FreeVec (afh);
  348.             }
  349.             else break;
  350.             }
  351.             
  352.             ReqToolsBase->AvailFontsHeader = afh;
  353.             if (dlist)
  354.             {
  355.             ReqToolsBase->FontsAssignType = dlist->dol_Type;
  356.             ReqToolsBase->FontsAssignLock = dlist->dol_Lock;
  357.             
  358.             if (dlist->dol_Type == DLT_DIRECTORY)
  359.             {
  360.                 assignlist = dlist->dol_misc.dol_assign.dol_List;
  361.                 prevassign = &(ReqToolsBase->FontsAssignList);
  362.  
  363.                 while (assignlist)
  364.                 {
  365.                 fontslist = AllocVec (sizeof (struct AssignList), MEMF_CLEAR);
  366.                 *prevassign = fontslist;
  367.                 
  368.                 if (!fontslist) break;
  369.                 
  370.                 fontslist->al_Lock = assignlist->al_Lock;
  371.                 assignlist = assignlist->al_Next;
  372.                 prevassign = &(fontslist->al_Next);
  373.                 
  374.                 }
  375.                 
  376.             }
  377.             
  378.             }
  379.             
  380.         } /* if (!afh) */
  381.             
  382.         UnLockDosList (LDF_DEVICES|LDF_ASSIGNS|LDF_READ);
  383.  
  384.         if (!afh)
  385.             DisplayBeep (NULL);
  386.         else
  387.         {
  388.             af = (struct AvailFonts *)((long)afh + 2);
  389.             for (i = 0; i < afh->afh_NumEntries; i++, af++)
  390.             {
  391.             if ((af->af_Type == AFF_MEMORY) &&
  392.                 !(af->af_Attr.ta_Flags & FPF_ROMFONT)) continue;
  393.                 
  394.             if (glob->filterhook)
  395.             {
  396.                 if (!CallHookPkt (glob->filterhook, fontreq, &af->af_Attr))
  397.                 continue;
  398.             }
  399.             else
  400.             {
  401.                 if (glob->flags & FREQF_DOWILDFUNC)
  402.                 {
  403.                 if (CallHook (fontreq->Hook, (Object *)fontreq,
  404.                           REQHOOK_WILDFONT, &af->af_Attr))
  405.                     continue;
  406.                 }
  407.             }
  408.             
  409.             str = af->af_Attr.ta_Name;
  410.             val = strlen(str) - 5;
  411.             str[val] = 0;
  412.             
  413.             if (!(entry = AddEntry (glob, buff, str, af->af_Attr.ta_YSize, FONT)))
  414.                 break;
  415.                 
  416.             str[val] = '.';
  417.             entry->re_Flags = af->af_Attr.ta_Flags;
  418.             entry->re_Style = af->af_Attr.ta_Style;
  419.             }
  420.                 
  421.             str = filename;
  422.             val = strlen(str) - 5;
  423.             str[val] = 0;
  424.             FindCurrentPos (glob, str, glob->fontreq->Attr.ta_YSize, FONT);
  425.             str[val] = '.';
  426.             
  427.         }
  428.         
  429.         ReqToolsBase->AvailFontsLock = FALSE;
  430.         RethinkReqDisplay (glob);
  431.         rtUnlockWindow (glob->reqwin, winlock);
  432.         
  433.         } /* else if (glob->reqtype == RT_FONTREQ) */
  434.         else
  435.         {
  436.         id = INVALID_ID;
  437.         while ((id = NextDisplayInfo (id)) != INVALID_ID)
  438.         {
  439.             if (glob->filterhook)
  440.             {
  441.             if (!CallHookPkt (glob->filterhook, glob->scrmodereq, (APTR)id))
  442.                 continue;
  443.             }
  444.             
  445.             /* filter out dual playfield modes */
  446.             if (id & DUALPF) continue;
  447.             /* filter out modes with default monitor */
  448.             if ((id & MONITOR_ID_MASK) == DEFAULT_MONITOR_ID) continue;
  449.             if (!GetModeData (glob, id, &mon)) continue;
  450.             /* is mode available ? */
  451.             if (glob->dispinfo.NotAvailable) continue;
  452.             if (!(entry = AddEntry (glob, buff, glob->nameinfo.Name, id, SCRMODE)))
  453.             break;
  454.         }
  455.         /* get mode data for currently selected mode */
  456.         GetModeData (glob, glob->modeid, &mon);
  457.         
  458.         if (!FindCurrentPos (glob, glob->nameinfo.Name, glob->modeid, SCRMODE))
  459.         {
  460.             if (glob->firstentry->re_Next)
  461.             {
  462.             glob->modeid  = (ULONG)(((struct ReqEntry *)glob->firstentry->re_Next)->re_Size);
  463.             SetTextGad (glob, glob->modetxtgad, ((struct ReqEntry *)glob->firstentry->re_Next)->re_Name);
  464.             GetModeData (glob, glob->modeid, &mon);
  465.             }
  466.             else
  467.             {
  468.             glob->modeid = INVALID_ID;
  469.             SetTextGad (glob, glob->modetxtgad, NULL);
  470.             
  471.             if (glob->depthgad)
  472.             {
  473.                 glob->currmindepth = glob->currmaxdepth = glob->maxdepth = glob->mindepth = glob->depth = 0;
  474.                 UpdateDepthGad (glob);
  475.                 myGT_SetGadgetAttrs (glob->maxcolgad, glob->reqwin, NULL, GTTX_Text, "0", TAG_END);
  476.             }
  477.             
  478.             if (glob->flags & SCREQF_SIZEGADS)
  479.             {
  480.                 myGT_SetGadgetAttrs (glob->widthgad, glob->reqwin, NULL, GA_Disabled, TRUE, TAG_END);
  481.                 myGT_SetGadgetAttrs (glob->defwgad, glob->reqwin, NULL, GA_Disabled, TRUE, TAG_END);
  482.                 myGT_SetGadgetAttrs (glob->heightgad, glob->reqwin, NULL, GA_Disabled, TRUE, TAG_END);
  483.                 myGT_SetGadgetAttrs (glob->defhgad, glob->reqwin, NULL, GA_Disabled, TRUE, TAG_END);
  484.             }
  485.             
  486.             if (glob->flags & SCREQF_OVERSCANGAD)
  487.                 myGT_SetGadgetAttrs (glob->overscangad, glob->reqwin, NULL, GA_Disabled, TRUE, TAG_END);
  488.             
  489.             if (glob->flags & SCREQF_AUTOSCROLLGAD)
  490.                 myGT_SetGadgetAttrs (glob->checkboxgad[CHECKBOX_AUTOSCROLL], glob->reqwin, NULL,
  491.                          GA_Disabled, TRUE, TAG_END);
  492.             }
  493.             
  494.         } /* else if (glob->reqtype == RT_FONTREQ)*/
  495.         
  496.         GetModeDimensions (glob);
  497.         DisplayModeAttrs (glob);
  498.         RethinkReqDisplay (glob);
  499.         }
  500.  
  501.     } /* if (!glob->bufferentry) */
  502.         
  503.     glob->bufferentry = glob->newdir = FALSE;
  504.  
  505.     } /* if (glob->newdir) */
  506.  
  507.     if (glob->exnext)
  508.     {
  509.     if ((glob->exnext = ExNext (glob->lock, &glob->fib)))
  510.     {
  511.         ULONG size = glob->fib.fib_Size;
  512.  
  513.         ctype = glob->fib.fib_EntryType;
  514.  
  515.         /* Try to examine links */
  516.         if( ( glob->fib.fib_EntryType == ST_SOFTLINK ) && ExpandLink( glob ) )
  517.         {
  518.         size = glob->linkfib.fib_Size;
  519.         ctype = glob->linkfib.fib_EntryType;
  520.         }
  521.  
  522.         /* Hooks */
  523.         if (glob->filterhook)
  524.         {
  525.         SetDrawerAndFileFields (glob);
  526.         val = CallHookPkt (glob->filterhook, freq, &glob->fib);
  527.         ResetDrawerAndFileFields (glob);
  528.         
  529.         if (!val) goto skipfile;
  530.         }
  531.         else
  532.         {
  533.         if (glob->flags & FREQF_DOWILDFUNC)
  534.         {
  535.             SetDrawerAndFileFields (glob);
  536.             val = CallHook (freq->Hook, (Object *)freq, REQHOOK_WILDFILE, &glob->fib);
  537.             ResetDrawerAndFileFields (glob);
  538.             
  539.             if (val) goto skipfile;
  540.         }
  541.         }
  542.  
  543.         ctype = ( ctype > 0 ) ? glob->directory_id : glob->file_id;
  544.  
  545.         if( !AddEntry( glob, buff, glob->fib.fib_FileName, size, ctype ) )
  546.         glob->exnext = FALSE;
  547.  
  548. skipfile:
  549.         ;
  550.         
  551.     } /* if ((glob->exnext = ExNext (glob->lock, &glob->fib))) */
  552.  
  553.     if (!glob->exnext)
  554.     {
  555.         UnLockReqLock (glob);
  556.         EndQuiet (glob);
  557.     }
  558.         
  559.     } /* if (glob->exnext) */
  560.  
  561.     do
  562.     {
  563.     reqmsg = NULL;
  564.     
  565.     while ((imsg = (struct IntuiMessage *)GetMsg (glob->reqwin->UserPort)))
  566.     {
  567.         /* Reply message from timer.device ? */
  568.         if ((struct timerequest *)imsg == &glob->timereq)
  569.         {
  570.         glob->timerstarted = FALSE;
  571.         EndQuiet (glob);
  572.         continue;
  573.         }
  574.         
  575.         /* Message from string gadget hook ? */
  576.         if (!imsg->Class && !imsg->Seconds)
  577.         {
  578.         /* Mark message so string gadget hook knows it has been received */
  579.         imsg->Micros = 0;
  580.         
  581.         if (glob->selectedpos != -1)
  582.         {
  583.             DeselectFiles (glob, -1, FALSE);
  584.             CountAllDeselect (glob, FALSE);
  585.             UpdateNumSelGad (glob);
  586.             glob->selectedpos = -1;
  587.         }
  588.         
  589.         if (*glob->filestr && !glob->disks)
  590.             FindEntryPos (glob, glob->filestr, glob->file_id);
  591.         continue;
  592.         }
  593.         
  594.         if ((reqmsg = ProcessWin_Msg_Freq (glob, imsg))) break;
  595.     }
  596.  
  597.     if (reqmsg)
  598.     {
  599.         memcpy( &im, reqmsg, sizeof( im ) );
  600.         Reply_GT_Msg (reqmsg);
  601.  
  602.         gad = (struct Gadget *)im.IAddress;
  603.         code = im.Code;
  604.         qual = im.Qualifier;
  605.  
  606.         switch (im.Class)
  607.         {
  608.         case IDCMP_DISKINSERTED:
  609.         case IDCMP_DISKREMOVED:
  610.             if (glob->disks)
  611.             {
  612.             glob->disks = FALSE;
  613.             ShowDisks (glob);
  614.             }
  615.             break;
  616.             
  617.         case IDCMP_REFRESHWINDOW:
  618.             RenderReqWindow (glob, TRUE, FALSE);
  619.             break;
  620.             
  621.         case IDCMP_CLOSEWINDOW:
  622.             FreeAllCheckBuffer (glob);
  623.             return (FALSE);
  624.             
  625.         case IDCMP_NEWSIZE:
  626.             if (glob->filegad)
  627.             {
  628.             strcpy (glob->tempfname, glob->filestr);
  629.             }
  630.             RemoveGList (glob->reqwin, glob->buttoninfo.glist, -1);
  631.             my_FreeGadgets (glob->buttoninfo.glist);
  632.             glob->buttoninfo.glist = NULL;
  633.             my_FreeLabelImages (&glob->labelimages);
  634.             glob->labelimages.NextImage = NULL;
  635.             glob->reqheight = glob->reqwin->Height;
  636.             
  637.             if (!SetupReqWindow (glob, TRUE))
  638.             {
  639.             glob->reqheight = glob->reqwin->MinHeight;
  640.             glob->reqwidth = glob->reqwin->MinWidth;
  641.             
  642.             if (!SetupReqWindow (glob, TRUE))
  643.             {
  644.                 DisplayBeep (NULL);
  645.                 FreeAllCheckBuffer (glob);
  646.                 return (FALSE);
  647.             }
  648.             }
  649.             
  650.             my_SetStringGadget (glob->reqwin, glob->filegad, glob->tempfname);
  651.             
  652.             if (!glob->nodir || glob->disks)
  653.             {
  654.             i = glob->buff->currentnum - glob->numentries;
  655.             
  656.             if (i < 0)
  657.                 glob->buff->gotopos = glob->buff->pos = 0;
  658.             else if (glob->buff->pos > i)
  659.                 glob->buff->gotopos = glob->buff->pos = i;
  660.                 
  661.             AdjustScroller (glob);
  662.             UpdateDisplayList (glob);
  663.             PrintFiles (glob);
  664.             }
  665.             RenderReqWindow (glob, FALSE, FALSE);
  666.             break;
  667.             
  668.         case IDCMP_MOUSEMOVE:
  669.             if (!glob->downgadget) break;
  670.                         
  671.             if (glob->downgadget == FILES)
  672.             {
  673.             if (glob->clicked != ~0)
  674.             {
  675.                 clicked = CalcClicked (glob, &im);
  676.                 sel = !(glob->displaylist[glob->clicked]->re_Flags & ENTRYF_HIGHLIGHTED);
  677.                 val = !(clicked != glob->clicked || im.MouseX < glob->boxleft
  678.                   || im.MouseX > glob->boxright);
  679.                 if (val == sel) CompClicked (glob);
  680.             }
  681.             }
  682.             else if (gad->GadgetID == FPROP) ScrollerMoved (glob, code);
  683.             else if (gad->GadgetID == DEPTH) UpdateDepthDisplay (glob, code, glob->modeid);
  684.             break;
  685.             
  686.         case IDCMP_MOUSEBUTTONS:
  687.             glob->downgadget = 0;
  688.  
  689.             if( glob->reqtype == RT_FILEREQ )
  690.             {
  691.             if( ( code == MENUDOWN ) && !glob->volumerequest )
  692.             {
  693.                 if( !glob->disks )
  694.                 {
  695.                 ShowDisks( glob );
  696.                 }
  697.                 else
  698.                 {
  699.                 strcpy( fdir, glob->drawerstr );
  700.                 NewDir( glob );
  701.                 }
  702.             }
  703.             else if( code == MIDDLEDOWN )
  704.             {
  705.                 BOOL doit;
  706.  
  707.                 doit = rtLockPrefs()->Flags & RTPRF_MMBPARENT;
  708.                 rtUnlockPrefs();
  709.  
  710.                 if( doit )
  711.                 {
  712.                 goto parentdir;
  713.                 }
  714.             }
  715.             }
  716.  
  717.             break;
  718.             
  719.         case IDCMP_GADGETDOWN:
  720.             EndQuiet (glob);
  721.             glob->downgadget = id = gad->GadgetID;
  722.             if (id == FILES)
  723.             {
  724.             glob->clicked = ~0;
  725.             clicked = CalcClicked (glob, &im);
  726.             if (ClickDown (glob, clicked, &im, qual))
  727.                 return (LeaveReq (glob, filename));
  728.             }
  729.             else if (id == FPROP) 
  730.             {
  731.                 ScrollerMoved (glob, code);
  732.             }
  733.             break;
  734.             
  735.         case IDCMP_RAWKEY:
  736.             if ((glob->reqtype == RT_FILEREQ) && !(glob->flags & FREQF_NOFILES) &&
  737.              (code == RAWKEY_UP || code == RAWKEY_DOWN))
  738.             {
  739.             glob->activegadget = glob->mainstrgad;
  740.             
  741.             if (glob->selectcurrpos || !glob->buff->firstname) break;
  742.             
  743.             lastpos = glob->selectedpos;
  744.             
  745.             if (glob->selectedpos == -1)
  746.             {
  747.                 if (qual & IEQUALIFIER_SHIFT)
  748.                 {
  749.                 if (code == RAWKEY_UP)
  750.                     glob->selectedpos = glob->buff->pos;
  751.                 else
  752.                     glob->selectedpos = glob->buff->pos +
  753.                             MIN (glob->numentries, glob->buff->currentnum)  - 1;
  754.                 }
  755.                 else if (qual & IEQUALIFIER_CONTROL)
  756.                 {
  757.                  if (code == RAWKEY_UP) glob->selectedpos = 0;
  758.                  else glob->selectedpos = glob->buff->currentnum - 1;
  759.                 }
  760.                 else
  761.                 {
  762.                 if (glob->disks) i = (qual & IEQUALIFIER_ALT) ? ASSIGN : VOLUME;
  763.                 else i = (qual & IEQUALIFIER_ALT) ? glob->directory_id : glob->file_id;
  764.                 glob->selectedpos = FindEntryPos (glob, glob->filestr, i);
  765.                 }
  766.             }
  767.             else
  768.             {
  769.                 if (code == RAWKEY_UP)
  770.                 {
  771.                 if (qual & IEQUALIFIER_SHIFT)
  772.                 {
  773.                     if (glob->selectedpos != glob->buff->pos)
  774.                         glob->selectedpos = glob->buff->pos;
  775.                     else glob->selectedpos -= (glob->numentries - 1);
  776.                     if (glob->selectedpos < 0) glob->selectedpos = 0;
  777.                 }
  778.                 else if (qual & IEQUALIFIER_CONTROL)
  779.                     glob->selectedpos = 0;
  780.                 else if (glob->selectedpos) glob->selectedpos--;
  781.                 }
  782.                 else
  783.                 {
  784.                 if (qual & IEQUALIFIER_SHIFT)
  785.                 {
  786.                     val = (glob->buff->pos + glob->numentries - 1);
  787.                     if (glob->selectedpos != val) glob->selectedpos = val;
  788.                     else glob->selectedpos += glob->numentries - 1;
  789.                     if (glob->selectedpos >= glob->buff->currentnum)
  790.                         glob->selectedpos = glob->buff->currentnum - 1;
  791.                 }
  792.                 else if (qual & IEQUALIFIER_CONTROL)
  793.                     glob->selectedpos = glob->buff->currentnum - 1;
  794.                 else if (glob->selectedpos < (glob->buff->currentnum - 1))
  795.                     glob->selectedpos++;
  796.                 }
  797.             }
  798.             
  799.             if (glob->selectedpos != lastpos)
  800.             {
  801.                 i = (glob->selectedpos - glob->buff->pos);
  802.                 val = glob->buff->gotopos;
  803.                 
  804.                 if (i < 0)
  805.                 {
  806.                 val += i;
  807.                 if (val < 0) val = 0;
  808.                 }
  809.                 
  810.                 if (i >= glob->numentries)
  811.                 {
  812.                 val += (i - glob->numentries) + 1;
  813.                 if (val > (glob->buff->currentnum - glob->numentries))
  814.                     val = (glob->buff->currentnum - glob->numentries);
  815.                 }
  816.                 ScrollerMoved (glob, val);
  817.                 
  818.                 if (glob->buff->pos != glob->buff->gotopos)
  819.                 AdjustScroller (glob);
  820.                 
  821.                 glob->selectcurrpos = TRUE;
  822.             }
  823.             break;
  824.             }
  825.             
  826.             if ((id = CheckGadgetKey (code, qual, &key, &glob->buttoninfo)))
  827.             goto dogadgetup;
  828.                 
  829.             gad = NULL;
  830.             checkbox = -1;
  831.             
  832.             if (key == 27)    /* Esc? */
  833.             goto docancel;
  834.             else if (key == glob->gadkey[CHECKBOX_AUTOSCROLL])
  835.             checkbox = CHECKBOX_AUTOSCROLL;
  836.             else if (key == glob->gadkey[CHECKBOX_BOLD])
  837.             checkbox = CHECKBOX_BOLD;
  838.             else if (key == glob->gadkey[CHECKBOX_ITALIC])
  839.             checkbox = CHECKBOX_ITALIC;
  840.             else if (key == glob->gadkey[CHECKBOX_UNDERLINE])
  841.             checkbox = CHECKBOX_UNDERLINE;
  842.             else if (key == glob->patkey) gad = glob->patgad;
  843.             else if (key == glob->heightkey) gad = glob->heightgad;
  844.             else if (key == glob->widthkey) gad = glob->widthgad;
  845.             else if (key == glob->overscankey)
  846.             {
  847.             if (glob->overscangad)
  848.             {
  849.                 if (qual & IEQUALIFIER_SHIFT)
  850.                     glob->overscantype--;
  851.                 else
  852.                     glob->overscantype++;
  853.                 
  854.                 if (glob->overscantype > OSCAN_MAX) glob->overscantype = 0;
  855.                 if (glob->overscantype < 0) glob->overscantype = OSCAN_MAX;
  856.                 
  857.                 code = glob->overscantype;
  858.                 myGT_SetGadgetAttrs (glob->overscangad, glob->reqwin, NULL,
  859.                          GTCY_Active, code, TAG_END);
  860.                 id = OVERSCN;
  861.                 goto dogadgetup;
  862.             }
  863.             }
  864.             else if (key == glob->depthkey)
  865.             {
  866.             if (glob->depthgad)
  867.             {
  868.                 if (qual & IEQUALIFIER_SHIFT)
  869.                 {
  870.                 if (glob->depth > glob->currmindepth) glob->depth--;
  871.                 }
  872.                 else
  873.                 {
  874.                 if (glob->depth < glob->currmaxdepth) glob->depth++;
  875.                 }
  876.                 UpdateDepthGad (glob);
  877.             }
  878.             }
  879.             
  880.             if (gad) glob->activegadget = gad;
  881.             
  882.             if (checkbox != -1)
  883.             {
  884.             if ((gad = glob->checkboxgad[checkbox]))
  885.             {
  886.                 IPTR checked;
  887.                 struct TagItem get_tags[] =
  888.                 {
  889.                     {GTCB_Checked, (IPTR)&checked},
  890.                 {TAG_DONE                    }
  891.                 };
  892.                 
  893.                         #ifdef _AROS
  894.                 /* the other way (checking GFLG_SELECTED) does
  895.                    not work with AROS gadtools.library, and in
  896.                    general not with boopsi gadgets. Only with
  897.                    non-boopsi bool gadgets it works (but not
  898.                    yet in AROS) */
  899.                 
  900.                 GT_GetGadgetAttrsA(gad, glob->reqwin, NULL, get_tags);
  901.                 myGT_SetGadgetAttrs (gad, glob->reqwin, NULL,
  902.                              GTCB_Checked, !checked, TAG_END);
  903.                 
  904.             #else
  905.                 myGT_SetGadgetAttrs (gad, glob->reqwin, NULL,
  906.                              GTCB_Checked, !(gad->Flags & GFLG_SELECTED), TAG_END);
  907.                         #endif
  908.                 goto fakegadgetup;
  909.             }
  910.             }
  911.             break;
  912.             
  913.         case IDCMP_GADGETUP:
  914. #ifdef _AROS
  915.             /* AROS gadtools library gadgets are boopsi gadgets, so checking
  916.                for GTYP_STRGADGET does not work*/
  917.             if ((code == KEYB_SHORTCUT) && ((gad->GadgetID == PATSTR) ||
  918.                                 (gad->GadgetID == DRAWERSTR) ||
  919.                             (gad->GadgetID == FILESTR)) )
  920.  
  921.             
  922. #else
  923.             if (((gad->GadgetType & GTYP_GTYPEMASK) == GTYP_STRGADGET)
  924.             && (code == KEYB_SHORTCUT))
  925. #endif
  926.             {
  927.             doactgad = FALSE;
  928.             continue;
  929.             }
  930.  
  931. fakegadgetup:
  932.             id = gad->GadgetID;
  933. dogadgetup:
  934.             glob->downgadget = 0;
  935.             switch (id)
  936.             {
  937.             case FILES:
  938.                 clicked = CalcClicked (glob, &im);
  939.                 
  940.                 if (clicked != glob->clicked) break;
  941.                 
  942.                 entry = glob->displaylist[clicked];
  943.                 str = entry->re_Name;
  944.                 doubleclick = ((clicked == glob->lastclicked)
  945.                     && DoubleClick (glob->sec, glob->mic, im.Seconds, im.Micros));
  946.                 ctype = entry->re_Type;
  947.                 
  948.                 if (ctype == glob->directory_id)
  949.                 {
  950.                 if (!(glob->flags & FREQF_SELECTDIRS))
  951.                 {
  952.                     AddPart (fdir, str, 256);
  953.                     NewDir (glob);
  954.                     
  955.                     /* CHECKME: added hoping to fix MuForce hit. See below. */
  956.                     
  957.                     entry = NULL;
  958.                     
  959.                     /* END CHECKME */
  960.                     break;
  961.                 }
  962.                 }
  963.                 else switch (ctype)
  964.                 {
  965.                 case VOLUME:
  966.                 case ASSIGN:
  967.                     CompClicked (glob);
  968.                     if (ctype == VOLUME)
  969.                     {
  970.                     str2 = str;
  971.                     while (*str2 != ' ') str2++;
  972.                     str3 = str2;
  973.                     while (*str3 == ' ') str3++;
  974.                     if ((glob->volumerequest && !( *str == '-' && str[ 1 ] == ' ' ))
  975.                         || *str3 == ':'
  976.                         || FindVolume (glob, str3, entry))
  977.                     {
  978.                         strcpy (fdir, str);
  979.                         fdir[str2-str] = 0;
  980.                     }
  981.                     else strcpy (fdir, str3);
  982.                     }
  983.                     else strcpy (fdir, str);
  984.                     
  985.                     if (!glob->volumerequest)
  986.                     {
  987.                     NewDir (glob);
  988.  
  989.                     /* CHECKME: added hoping to fix MuForce hit. See below. */
  990.  
  991.                     entry = NULL;
  992.  
  993.                     /* END CHECKME */
  994.  
  995.                     break;
  996.                     }
  997.                    
  998.                     my_SetStringGadget (glob->reqwin, glob->drawergad, fdir);
  999. checkdoubleclick:
  1000.                     if (doubleclick)
  1001.                     return (LeaveReq (glob, filename));
  1002.  
  1003.                     goto rememberclicked;
  1004.                     
  1005.                 case FONT:
  1006.                     CompClicked (glob);
  1007.                     strcpy (filename, str);
  1008.                     StrCat (filename, DOTFONTSTR);
  1009.                     my_SetStringGadget (glob->reqwin,
  1010.                             glob->filegad, filename);
  1011.                     if (doubleclick)
  1012.                     return (LeaveReq (glob, filename));
  1013.  
  1014.                     fontreq->Attr.ta_YSize = entry->re_Size;
  1015.                     fontreq->Attr.ta_Flags = entry->re_Flags;
  1016.                     fontreq->Attr.ta_Style = entry->re_Style;
  1017.                     fontreq->Attr.ta_Style &= ~(FSF_ITALIC|FSF_BOLD|FSF_UNDERLINED);
  1018.                     fontreq->Attr.ta_Style |= glob->fontstyle;
  1019.                     my_SetIntegerGadget (glob->reqwin,
  1020.                              glob->drawergad, entry->re_Size);
  1021.                     ShowFontSample (glob, FALSE, TRUE);
  1022. rememberclicked:
  1023.                     glob->lastclicked = clicked;
  1024.                     glob->sec = im.Seconds; glob->mic = im.Micros;
  1025.                     break;
  1026.                     
  1027.                 case SCRMODE:
  1028.                     CompClicked (glob);
  1029.                     SetTextGad (glob, glob->modetxtgad, str);
  1030.                     glob->modeid = (ULONG)entry->re_Size;
  1031.                     if (!GetModeData (glob, glob->modeid, &mon))
  1032.                     DisplayBeep (glob->scr);
  1033.                     else
  1034.                     {
  1035.                     GetModeDimensions (glob);
  1036.                     DisplayModeAttrs (glob);
  1037.                     }
  1038.                     goto checkdoubleclick;
  1039.                 }
  1040.                 
  1041.                 #warning check following line. causes MuForces hits on Amiga when clicking
  1042.                 #warning on volume or assign entry. Both with old Amiga reqtools.library and
  1043.                 #warning in new reqtools.library compiled from AROS sources.
  1044.                 
  1045.             #if 0
  1046.                 entry->re_Flags &= ~ENTRYF_HIGHLIGHTED;
  1047.             #else                
  1048.                 if (entry) entry->re_Flags &= ~ENTRYF_HIGHLIGHTED;                
  1049.             #endif
  1050.                 break;
  1051.                 
  1052.             case FONTSIZE:
  1053.                 fontreq->Attr.ta_YSize = ((struct StringInfo *)glob->drawergad->SpecialInfo)->LongInt;
  1054.                 ShowFontSample (glob, FALSE, TRUE);
  1055.                 glob->activegadget = glob->mainstrgad;
  1056.                 break;
  1057.                 
  1058.             case ITALIC:
  1059.             #ifdef _AROS
  1060.                 {
  1061.                     IPTR checked;
  1062.                 struct TagItem get_tags[] =
  1063.                 {
  1064.                         {GTCB_Checked, (IPTR)&checked},
  1065.                     {TAG_DONE                }
  1066.                 };
  1067.                 
  1068.                 GT_GetGadgetAttrsA(glob->checkboxgad[CHECKBOX_ITALIC], glob->reqwin, NULL, get_tags);
  1069.                 if (checked) 
  1070.                                 {
  1071.                     glob->fontstyle |= FSF_ITALIC;
  1072.                 }
  1073.                 else
  1074.                 {
  1075.                     glob->fontstyle &= ~FSF_ITALIC;
  1076.                 }
  1077.                 }
  1078.                 
  1079.             #else
  1080.             
  1081.                 if (glob->checkboxgad[CHECKBOX_ITALIC]->Flags & GFLG_SELECTED)            
  1082.                 glob->fontstyle |= FSF_ITALIC;
  1083.                 else glob->fontstyle &= ~FSF_ITALIC;
  1084.                 
  1085.                         #endif
  1086.             
  1087.                 goto updatestyle;
  1088.                 
  1089.             case UNDERLINE:
  1090.             #ifdef _AROS
  1091.                 {
  1092.                     IPTR checked;
  1093.                 struct TagItem get_tags[] =
  1094.                 {
  1095.                         {GTCB_Checked, (IPTR)&checked},
  1096.                     {TAG_DONE                }
  1097.                 };
  1098.                 
  1099.                 GT_GetGadgetAttrsA(glob->checkboxgad[CHECKBOX_UNDERLINE], glob->reqwin, NULL, get_tags);
  1100.                 if (checked) 
  1101.                                 {
  1102.                     glob->fontstyle |= FSF_UNDERLINED;
  1103.                 }
  1104.                 else
  1105.                 {
  1106.                     glob->fontstyle &= ~FSF_UNDERLINED;
  1107.                 }
  1108.                 }
  1109.                 
  1110.             #else
  1111.             
  1112.                 if (glob->checkboxgad[CHECKBOX_UNDERLINE]->Flags & GFLG_SELECTED)
  1113.                 glob->fontstyle |= FSF_UNDERLINED;
  1114.                 else glob->fontstyle &= ~FSF_UNDERLINED;
  1115.             #endif
  1116.             
  1117.                 goto updatestyle;
  1118.                 
  1119.             case BOLD:
  1120.             #ifdef _AROS
  1121.                 {
  1122.                     IPTR checked;
  1123.                 struct TagItem get_tags[] =
  1124.                 {
  1125.                         {GTCB_Checked, (IPTR)&checked},
  1126.                     {TAG_DONE                }
  1127.                 };
  1128.                 
  1129.                 GT_GetGadgetAttrsA(glob->checkboxgad[CHECKBOX_BOLD], glob->reqwin, NULL, get_tags);
  1130.                 if (checked) 
  1131.                                 {
  1132.                     glob->fontstyle |= FSF_BOLD;
  1133.                 }
  1134.                 else
  1135.                 {
  1136.                     glob->fontstyle &= ~FSF_BOLD;
  1137.                 }
  1138.                 }
  1139.                 
  1140.             #else
  1141.             
  1142.                 if (glob->checkboxgad[CHECKBOX_BOLD]->Flags & GFLG_SELECTED)
  1143.                     glob->fontstyle |= FSF_BOLD;
  1144.                 else glob->fontstyle &= ~FSF_BOLD;
  1145.             #endif
  1146. updatestyle:
  1147.                 ShowFontSample (glob, FALSE, TRUE);
  1148.                 break;
  1149.                 
  1150.             case ALL:
  1151.                 EndQuiet (glob);
  1152.                 if (!glob->nodir && !glob->disks) SelectAll (glob, "#?");
  1153.                 break;
  1154.                 
  1155.             case PATTERN:
  1156.                 EndQuiet (glob);
  1157.                 if (!glob->nodir && !glob->disks)
  1158.                 {
  1159.                 struct TagItem tags[] =
  1160.                 {
  1161.                     {RT_Window        , (IPTR)glob->reqwin    },
  1162.                     {RT_IntuiMsgFunc    , (IPTR)&glob->intuihook},
  1163.                     {TAG_MORE        , (IPTR)getstringtags    }
  1164.                 };
  1165.  
  1166.                 if (rtGetStringA (glob->selpattern, 123,
  1167.                           GetStr (glob->catalog, MSG_MATCH_WINTITLE),
  1168.                           NULL, tags))
  1169.                     SelectAll (glob, glob->selpattern);
  1170.                 }
  1171.                 break;
  1172.  
  1173.             case CLR:
  1174.                 EndQuiet (glob);
  1175.                 if (!glob->nodir && !glob->disks)
  1176.                 {
  1177.                 CountAllDeselect (glob, FALSE);
  1178.                 UpdateNumSelGad (glob);
  1179.                 PrintFiles (glob);
  1180.                 my_SetStringGadget (glob->reqwin, glob->filegad, "");
  1181.                 }
  1182.                 break;
  1183.                 
  1184.             case PATSTR:
  1185.                 EndQuiet (glob);
  1186.                 if (Stricmp (freq->patstr, glob->patgadstr))
  1187.                 {
  1188.                 strcpy (freq->patstr, glob->patgadstr);
  1189.                 ParsePatternNoCase (freq->patstr, glob->matchpat, sizeof( glob->matchpat ) );
  1190.                 glob->activegadget = glob->mainstrgad;
  1191.                 goto refreshlist;
  1192.                 }
  1193.                 glob->activegadget = glob->mainstrgad;
  1194.                 break;
  1195.                 
  1196.             case INFO:
  1197.                 EndQuiet (glob);
  1198.                 freq->hideinfo = !freq->hideinfo;
  1199. refreshlist:
  1200.                 RethinkReqDisplay (glob);
  1201.                 UpdateNumSelGad (glob);
  1202.                 break;
  1203.                 
  1204.             case DRAWERSTR:
  1205.                 glob->activegadget = glob->mainstrgad;
  1206.                 
  1207.                 if (glob->flags & FREQF_NOFILES)
  1208.                 {
  1209.                 if (glob->volumerequest ||
  1210.                     (!glob->nodir && !Stricmp (fdir, glob->drawerstr)))
  1211.                 {
  1212.                     if (qual & IEQUALIFIER_SHIFT) break;
  1213.                     
  1214.                     strcpy (fdir, glob->drawerstr);
  1215.                     val = (glob->volumerequest && !*fdir);
  1216.                     my_SelectGadget (!val ? glob->okgad : glob->cancelgad, glob->reqwin);
  1217.                     ShortDelay();
  1218.                     
  1219.                     if (val) goto docancel;
  1220.                     
  1221.                     return (LeaveReq (glob, filename));
  1222.                 }
  1223.                 }
  1224.                 
  1225.                 if (!glob->nodir && !glob->disks
  1226.                 && !Stricmp (fdir, glob->drawerstr))
  1227.                 break;
  1228.                 
  1229.                 /* FALLTHROUGH */
  1230.                 
  1231.             case GETDIR:
  1232.                 strcpy (fdir, glob->drawerstr);
  1233.                 NewDir (glob);
  1234.                 break;
  1235.                 
  1236.             case FILESTR:
  1237.                 if (code == 0x09) break;
  1238.                 
  1239.                 if (qual & IEQUALIFIER_SHIFT)
  1240.                 {
  1241.                 glob->activegadget = glob->drawergad;
  1242.                 break;
  1243.                 }
  1244.                 
  1245.                 if ((qual & IEQUALIFIER_ALT) && (glob->flags & FREQF_PATGAD))
  1246.                 {
  1247.                 glob->activegadget = glob->patgad;
  1248.                 break;
  1249.                 }
  1250.  
  1251.                 if (glob->reqtype == RT_FILEREQ)
  1252.                 {
  1253.                 /* extract path from filename if one was entered */
  1254.                 char tempstr[108];
  1255.                 BPTR templock = NULL, dirlock, oldcd;
  1256.  
  1257.                 str = glob->filestr;
  1258.  
  1259.                 if (*str == '/') {
  1260.                     strcpy (tempstr, str + 1);
  1261.                     my_SetStringGadget (glob->reqwin, glob->filegad,
  1262.                                 tempstr);
  1263.                     goto parentdir;
  1264.                     }
  1265.  
  1266.                 if (*str)
  1267.                 {
  1268.                     *glob->winaddr = (APTR)-1;
  1269.                     
  1270.                     if ((dirlock = Lock (glob->drawerstr, SHARED_LOCK)))
  1271.                     {
  1272.                     oldcd = CurrentDir (dirlock);
  1273.                     templock = Lock (str, SHARED_LOCK);
  1274.                     CurrentDir (oldcd);
  1275.                     }
  1276.                     
  1277.                     *glob->winaddr = glob->reqwin;
  1278.                     
  1279.                     if (dirlock) UnLock (dirlock);
  1280.                     
  1281.                     if (templock)
  1282.                     {
  1283.                     Examine (templock, &glob->fib);
  1284.                     UnLock (templock);
  1285.                     
  1286.                     if (glob->fib.fib_EntryType > 0)
  1287.                     {
  1288.                         if (dirlock)
  1289.                         {
  1290.                         strcpy (fdir, glob->drawerstr);
  1291.                         AddPart (fdir, str, 256);
  1292.                         }
  1293.                         else strcpy (fdir, str);
  1294.                         
  1295.                         tempstr[0] = 0;
  1296.                         
  1297.                         goto setfnamedirgads;
  1298.                     }
  1299.                     }
  1300.                 }
  1301.  
  1302.                 if (PathPart (str) != str)
  1303.                 {
  1304.                     val = strlen (str);
  1305.                     
  1306.                     for (i = 0; i < val; i++)
  1307.                     {
  1308.                     if (str[i] == ':')
  1309.                     {
  1310.                         strcpy (fdir, str);
  1311.                         break;
  1312.                     }
  1313.                     }
  1314.                     
  1315.                     if (i >= val) AddPart (fdir, str, 256);
  1316.                     
  1317.                     *(PathPart (fdir)) = 0;
  1318.                     strcpy (tempstr, FilePart (glob->filestr));
  1319. setfnamedirgads:
  1320.                     NewDir (glob);
  1321.                     my_SetStringGadget (glob->reqwin, glob->filegad, tempstr);
  1322.                     my_SetStringGadget (glob->reqwin, glob->drawergad, fdir);
  1323.                     break;
  1324.                     
  1325.                 }
  1326.                 
  1327.                 } /* if (glob->reqtype == RT_FILEREQ) */
  1328.  
  1329.                 my_SelectGadget (
  1330.                 (!glob->nodir &&
  1331.                     (*glob->filestr || glob->allowempty
  1332.                             || ((glob->flags & FREQF_MULTISELECT) &&
  1333.                             (glob->numselected > 0))
  1334.                     )
  1335.                 ) ? glob->okgad : glob->cancelgad, glob->reqwin);
  1336.                 ShortDelay();
  1337.  
  1338.             case OK:
  1339.                 return (LeaveReq (glob, filename));
  1340.                 
  1341.             case CANCEL:
  1342. docancel:
  1343.                 FreeAllCheckBuffer (glob);
  1344.                 return (FALSE);
  1345.                 
  1346.             case PARENT:
  1347. parentdir:
  1348.                 UnLockReqLock (glob);
  1349. //                strcpy (fdir, glob->drawerstr);
  1350.                 str = PathPart ( fdir );
  1351.                 if (*str)
  1352.                 {
  1353.                 *str = 0;
  1354.                 my_SetStringGadget (glob->reqwin, glob->drawergad, fdir);
  1355.                 NewDir (glob);
  1356.                 break;
  1357.                 }
  1358.                 else 
  1359.                 {
  1360.                 if ((glob->lock = Lock (glob->drawerstr, SHARED_LOCK)))
  1361.                 {
  1362.                     if ((parent = ParentDir (glob->lock)))
  1363.                     {
  1364.                     NameFromLock (parent, fdir, 256);
  1365.                     UnLock (parent);
  1366.                     NewDir (glob);
  1367.                     break;
  1368.                     }
  1369.                 }
  1370.                 }
  1371.  
  1372.                 if(glob->disks)
  1373.                     break;
  1374.                 /* FALLTHROUGH! */
  1375.                 
  1376.             case DISKS:
  1377.                 if (!glob->disks)
  1378.                 ShowDisks (glob);
  1379.                 else
  1380.                 {
  1381.                 strcpy (fdir, glob->drawerstr);
  1382.                 NewDir (glob);
  1383.                 }
  1384.                 break;
  1385.                 
  1386.             case DEPTH:
  1387.                 UpdateDepthDisplay (glob, code, glob->modeid);
  1388.                 glob->depth = code;
  1389.                 break;
  1390.                 
  1391.             case SCRWIDTH:
  1392.                 glob->width = IntGadgetBounds (glob, glob->widthgad,
  1393.                     MAX (glob->diminfo.MinRasterWidth, glob->minwidth),
  1394.                     MIN (glob->diminfo.MaxRasterWidth, glob->maxwidth));
  1395.                 glob->usedefwidth = (glob->width == glob->defwidth);
  1396.                 myGT_SetGadgetAttrs (glob->defwgad, glob->reqwin, NULL,
  1397.                          GTCB_Checked, glob->usedefwidth, TAG_END);
  1398.                 glob->activegadget = glob->mainstrgad;
  1399.                 break;
  1400.                 
  1401.             case SCRHEIGHT:
  1402.                 glob->height = IntGadgetBounds (glob, glob->heightgad,
  1403.                                 MAX (glob->diminfo.MinRasterHeight, glob->minheight),
  1404.                                 MIN (glob->diminfo.MaxRasterHeight, glob->maxheight));
  1405.                 glob->usedefheight = (glob->height == glob->defheight);
  1406.                 myGT_SetGadgetAttrs (glob->defhgad, glob->reqwin, NULL,
  1407.                          GTCB_Checked, glob->usedefheight, TAG_END);
  1408.                 glob->activegadget = glob->mainstrgad;
  1409.                 break;
  1410.                 
  1411.             case DEFWIDTH:
  1412.                 glob->usedefwidth = !glob->usedefwidth;
  1413.                 SetSizeGads (glob);
  1414.                 break;
  1415.                 
  1416.             case DEFHEIGHT:
  1417.                 glob->usedefheight = !glob->usedefheight;
  1418.                 SetSizeGads (glob);
  1419.                 break;
  1420.                 
  1421.             case AUTOSCR:
  1422.                 glob->autoscroll = !glob->autoscroll;
  1423.                 break;
  1424.                 
  1425.             case OVERSCN:
  1426.                 glob->overscantype = code;
  1427.                 GetModeDimensions (glob);
  1428.                 SetSizeGads (glob);
  1429.                 break;
  1430.                 
  1431.             } /* switch (id) */
  1432.             break;
  1433.  
  1434.         } /* switch (im.Class) */
  1435.  
  1436.     } /* if (reqmsg) */
  1437.  
  1438. iterate:
  1439.     if ((glob->downgadget != FILES) && (glob->buff->gotopos != glob->buff->pos))
  1440.     {
  1441.     #if NO_SCROLLWINDOWRASTER
  1442.         BOOL refreshall = FALSE;
  1443.     #endif
  1444.     
  1445.         start = 0; stop = glob->numentries;
  1446.         step = glob->buff->gotopos - glob->buff->pos;
  1447.         
  1448.         if (ABS(step) < stop)
  1449.         {
  1450.         if (ABS(step) > 1) step /= 2;
  1451.         if (step > 3) step = 3;
  1452.         if (step < -3) step = -3;
  1453.         
  1454.         SetBPen (glob->reqrp, glob->pens[BACKGROUNDPEN]);
  1455.         mySetWriteMask (glob->reqrp, glob->entrymask);
  1456.         
  1457.             #if !NO_SCROLLWINDOWRASTER
  1458.         if (glob->os30)
  1459.         {
  1460.             ScrollWindowRaster (glob->reqwin, 0, step * glob->entryheight,
  1461.                     glob->boxleft, glob->boxtop, glob->boxright,
  1462.                     glob->boxtop + glob->boxheight - 1);
  1463.         }
  1464.         else
  1465.         {
  1466.         #endif
  1467.             ScrollRaster (glob->reqrp, 0, step * glob->entryheight,
  1468.                   glob->boxleft, glob->boxtop, glob->boxright,
  1469.                   glob->boxtop + glob->boxheight - 1);
  1470.             if (glob->reqrp->Layer->Flags & LAYERREFRESH)
  1471.                 refreshall = TRUE; /* RenderReqWindow (glob, TRUE, FALSE); */
  1472.             
  1473.         #if !NO_SCROLLWINDOWRASTER
  1474.         }
  1475.         #endif
  1476.         mySetWriteMask (glob->reqrp, glob->rpmask);
  1477.  
  1478.         if (step > 0)
  1479.             start = stop - step;
  1480.         else
  1481.             stop = -step;
  1482.             
  1483.         } /* if (ABS(step) < stop) */
  1484.         
  1485.         glob->buff->pos += step;
  1486.         UpdateDisplayList (glob);
  1487.         
  1488.     #if NO_SCROLLWINDOWRASTER
  1489.         if (refreshall)
  1490.         {
  1491.             RenderReqWindow (glob, TRUE, FALSE);
  1492.         }
  1493.     #endif
  1494.  
  1495.         for (i = start; i < stop; i++) PrintEntry (glob, i);
  1496.         
  1497.         glob->DoNotWait = TRUE;
  1498.         
  1499.     } /* if ((glob->downgadget != FILES) && (glob->buff->gotopos != glob->buff->pos)) */
  1500.     else
  1501.     {
  1502.         glob->DoNotWait = glob->exnext || glob->newdir;
  1503.     }
  1504.     
  1505.     if (glob->selectcurrpos && (glob->buff->pos == glob->buff->gotopos))
  1506.     {
  1507.         if (glob->selectedpos != -1)
  1508.         {
  1509.         ClickDown (glob, (glob->selectedpos - glob->buff->pos), NULL, NULL);
  1510.         }
  1511.         glob->selectcurrpos = FALSE;
  1512.     }
  1513.  
  1514.     } while (reqmsg && !glob->newdir);
  1515.  
  1516.     if (doactgad)
  1517.     {
  1518. /*
  1519. #ifdef _AROS
  1520. #warning Disabled this gadget activation here, as in Intuition this functions is slow (why? ask stegerg)
  1521. #else
  1522. */
  1523.     ActivateGadget (glob->activegadget, glob->reqwin, NULL);
  1524.  
  1525. /*
  1526. #endif
  1527. */
  1528.     if (!(glob->reqwin->IDCMPFlags & IDCMP_RAWKEY))
  1529.     {
  1530.         /* Add RAWKEY IDCMP only after initialzing and refreshing the window */
  1531.         ModifyIDCMP (glob->reqwin, IDCMP_RAWKEY|REQ_IDCMP);
  1532.     }
  1533.     }
  1534.  
  1535.     return ((ULONG)CALL_HANDLER);
  1536. }
  1537.  
  1538. /****************************************************************************************/
  1539.